import httpFetch from 'share/httpFetch';
import config from 'config';
import errorMessage from 'share/errorMessage';
export default {
  getAllDataBySearchParams(searchParams) {
    return Promise.all([
      this.getUserFeeDetailReport(searchParams),
      this.getExcessExpFeeDetailReport(searchParams),
      this.getExcessExpPersonDetailReport(searchParams),
    ]);
  },
  //二维表的接口
  getUserFeeDetailReport(params){
    return new Promise((resolve, reject) => {
      httpFetch.post(config.baseUrl + '/report/api/report/search', params)
        .then((response) => {
          response.data = response.data.filter(item => {
            if (item + "" !== "null" && item + "" !== "undefined") {
              return item;
            }
          })
          resolve(response)
        })
        .catch(function (err) {
          errorMessage(err.response);
          reject(err.response);
        })
    })
  },
  //费用超标top
  getExcessExpFeeDetailReport(params){
    return new Promise((resolve, reject) => {
      httpFetch.post(config.baseUrl + '/report/api/excess/detail/exp/search', params)
        .then((response) => {
          resolve(response)
        })
        .catch(function (err) {
          errorMessage(err.response);
          reject(err.response);
        })
    })
  },
  //人员超标top
  getExcessExpPersonDetailReport(params){
    return new Promise((resolve, reject) => {
      httpFetch.post(config.baseUrl + '/report/api/excess/detail/user/search', params)
        .then((response) => {
          resolve(response)
        })
        .catch(function (err) {
          errorMessage(err.response);
          reject(err.response);
        })
    })
  },
}
